<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>

    /*返回promise的api
        new Promise()
        Promise.prototype.then
        Promise.prototype.catch
        Promise.resolve()
        Promise.reject()
        async函数
    */


   /* var id1 = setTimeout(function (flag) {
        if(flag){
            console.log("第一次請求成功")
        }else{
        }
    },1000,true);
    Promise.resolve(id1).then(()=>{
        var id2 = setTimeout(function (flag) {
            if(flag){
                console.log("第二次請求成功")
            }else{
            }
        },1000,true);
        Promise.resolve(id2).then(()=>{
            var id3 = setTimeout(function (flag) {
                if(flag){
                    console.log("第三次請求成功")
                }
            },1000,true);
            Promise.resolve(id3).then(()=>{
                console.log("----")
            })
        })
    })*/



    //语法糖
    async function f() {
        await setTimeout(function (flag) {
            if(flag){
                console.log("第一次請求成功")
            }else{
            }
        },1000,true)

        await setTimeout(function (flag) {
            if(flag){
                console.log("第二次請求成功")
            }else{
            }
        },1000,true)

        await setTimeout(function (flag) {
            if(flag){
                console.log("第三次請求成功")
            }
        },1000,true)

        console.log("----")
    }
    f()




</script>
</html>